{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport hash from '@emotion/hash';\nimport { ATTR_TOKEN, CSS_IN_JS_INSTANCE, CSS_IN_JS_INSTANCE_ID } from \"../StyleContext\";\nimport useGlobalCache from \"./useGlobalCache\";\nimport { flattenToken, token2key } from \"../util\";\nvar EMPTY_OVERRIDE = {}; // Generate different prefix to make user selector break in production env.\n// This helps developer not to do style override directly on the hash id.\n\nvar hashPrefix = process.env.NODE_ENV !== 'production' ? 'css-dev-only-do-not-override' : 'css';\nvar tokenKeys = new Map();\nfunction recordCleanToken(tokenKey) {\n  tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) + 1);\n}\nfunction removeStyleTags(key) {\n  if (typeof document !== 'undefined') {\n    var styles = document.querySelectorAll(\"style[\".concat(ATTR_TOKEN, \"=\\\"\").concat(key, \"\\\"]\"));\n    styles.forEach(function (style) {\n      if (style[CSS_IN_JS_INSTANCE] === CSS_IN_JS_INSTANCE_ID) {\n        var _style$parentNode;\n        (_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 ? void 0 : _style$parentNode.removeChild(style);\n      }\n    });\n  }\n} // Remove will check current keys first\n\nfunction cleanTokenStyle(tokenKey) {\n  tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) - 1);\n  var tokenKeyList = Array.from(tokenKeys.keys());\n  var cleanableKeyList = tokenKeyList.filter(function (key) {\n    var count = tokenKeys.get(key) || 0;\n    return count <= 0;\n  });\n  if (cleanableKeyList.length < tokenKeyList.length) {\n    cleanableKeyList.forEach(function (key) {\n      removeStyleTags(key);\n      tokenKeys.delete(key);\n    });\n  }\n}\n/**\n * Cache theme derivative token as global shared one\n * @param theme Theme entity\n * @param tokens List of tokens, used for cache. Please do not dynamic generate object directly\n * @param option Additional config\n * @returns Call Theme.getDerivativeToken(tokenObject) to get token\n */\n\nexport default function useCacheToken(theme, tokens) {\n  var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n  var _option$salt = option.salt,\n    salt = _option$salt === void 0 ? '' : _option$salt,\n    _option$override = option.override,\n    override = _option$override === void 0 ? EMPTY_OVERRIDE : _option$override,\n    formatToken = option.formatToken; // Basic - We do basic cache here\n\n  var mergedToken = React.useMemo(function () {\n    return Object.assign.apply(Object, [{}].concat(_toConsumableArray(tokens)));\n  }, [tokens]);\n  var tokenStr = React.useMemo(function () {\n    return flattenToken(mergedToken);\n  }, [mergedToken]);\n  var overrideTokenStr = React.useMemo(function () {\n    return flattenToken(override);\n  }, [override]);\n  var cachedToken = useGlobalCache('token', [salt, theme.id, tokenStr, overrideTokenStr], function () {\n    var derivativeToken = theme.getDerivativeToken(mergedToken); // Merge with override\n\n    var mergedDerivativeToken = _objectSpread(_objectSpread({}, derivativeToken), override); // Format if needed\n\n    if (formatToken) {\n      mergedDerivativeToken = formatToken(mergedDerivativeToken);\n    } // Optimize for `useStyleRegister` performance\n\n    var tokenKey = token2key(mergedDerivativeToken, salt);\n    mergedDerivativeToken._tokenKey = tokenKey;\n    recordCleanToken(tokenKey);\n    var hashId = \"\".concat(hashPrefix, \"-\").concat(hash(tokenKey));\n    mergedDerivativeToken._hashId = hashId; // Not used\n\n    return [mergedDerivativeToken, hashId];\n  }, function (cache) {\n    // Remove token will remove all related style\n    cleanTokenStyle(cache[0]._tokenKey);\n  });\n  return cachedToken;\n}","map":{"version":3,"names":["_objectSpread","_toConsumableArray","React","hash","ATTR_TOKEN","CSS_IN_JS_INSTANCE","CSS_IN_JS_INSTANCE_ID","useGlobalCache","flattenToken","token2key","EMPTY_OVERRIDE","hashPrefix","process","env","NODE_ENV","tokenKeys","Map","recordCleanToken","tokenKey","set","get","removeStyleTags","key","document","styles","querySelectorAll","concat","forEach","style","_style$parentNode","parentNode","removeChild","cleanTokenStyle","tokenKeyList","Array","from","keys","cleanableKeyList","filter","count","length","delete","useCacheToken","theme","tokens","option","arguments","undefined","_option$salt","salt","_option$override","override","formatToken","mergedToken","useMemo","Object","assign","apply","tokenStr","overrideTokenStr","cachedToken","id","derivativeToken","getDerivativeToken","mergedDerivativeToken","_tokenKey","hashId","_hashId","cache"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@ant-design/cssinjs/es/hooks/useCacheToken.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport hash from '@emotion/hash';\nimport { ATTR_TOKEN, CSS_IN_JS_INSTANCE, CSS_IN_JS_INSTANCE_ID } from \"../StyleContext\";\nimport useGlobalCache from \"./useGlobalCache\";\nimport { flattenToken, token2key } from \"../util\";\nvar EMPTY_OVERRIDE = {}; // Generate different prefix to make user selector break in production env.\n// This helps developer not to do style override directly on the hash id.\n\nvar hashPrefix = process.env.NODE_ENV !== 'production' ? 'css-dev-only-do-not-override' : 'css';\nvar tokenKeys = new Map();\n\nfunction recordCleanToken(tokenKey) {\n  tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) + 1);\n}\n\nfunction removeStyleTags(key) {\n  if (typeof document !== 'undefined') {\n    var styles = document.querySelectorAll(\"style[\".concat(ATTR_TOKEN, \"=\\\"\").concat(key, \"\\\"]\"));\n    styles.forEach(function (style) {\n      if (style[CSS_IN_JS_INSTANCE] === CSS_IN_JS_INSTANCE_ID) {\n        var _style$parentNode;\n\n        (_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 ? void 0 : _style$parentNode.removeChild(style);\n      }\n    });\n  }\n} // Remove will check current keys first\n\n\nfunction cleanTokenStyle(tokenKey) {\n  tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) - 1);\n  var tokenKeyList = Array.from(tokenKeys.keys());\n  var cleanableKeyList = tokenKeyList.filter(function (key) {\n    var count = tokenKeys.get(key) || 0;\n    return count <= 0;\n  });\n\n  if (cleanableKeyList.length < tokenKeyList.length) {\n    cleanableKeyList.forEach(function (key) {\n      removeStyleTags(key);\n      tokenKeys.delete(key);\n    });\n  }\n}\n/**\n * Cache theme derivative token as global shared one\n * @param theme Theme entity\n * @param tokens List of tokens, used for cache. Please do not dynamic generate object directly\n * @param option Additional config\n * @returns Call Theme.getDerivativeToken(tokenObject) to get token\n */\n\n\nexport default function useCacheToken(theme, tokens) {\n  var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n  var _option$salt = option.salt,\n      salt = _option$salt === void 0 ? '' : _option$salt,\n      _option$override = option.override,\n      override = _option$override === void 0 ? EMPTY_OVERRIDE : _option$override,\n      formatToken = option.formatToken; // Basic - We do basic cache here\n\n  var mergedToken = React.useMemo(function () {\n    return Object.assign.apply(Object, [{}].concat(_toConsumableArray(tokens)));\n  }, [tokens]);\n  var tokenStr = React.useMemo(function () {\n    return flattenToken(mergedToken);\n  }, [mergedToken]);\n  var overrideTokenStr = React.useMemo(function () {\n    return flattenToken(override);\n  }, [override]);\n  var cachedToken = useGlobalCache('token', [salt, theme.id, tokenStr, overrideTokenStr], function () {\n    var derivativeToken = theme.getDerivativeToken(mergedToken); // Merge with override\n\n    var mergedDerivativeToken = _objectSpread(_objectSpread({}, derivativeToken), override); // Format if needed\n\n\n    if (formatToken) {\n      mergedDerivativeToken = formatToken(mergedDerivativeToken);\n    } // Optimize for `useStyleRegister` performance\n\n\n    var tokenKey = token2key(mergedDerivativeToken, salt);\n    mergedDerivativeToken._tokenKey = tokenKey;\n    recordCleanToken(tokenKey);\n    var hashId = \"\".concat(hashPrefix, \"-\").concat(hash(tokenKey));\n    mergedDerivativeToken._hashId = hashId; // Not used\n\n    return [mergedDerivativeToken, hashId];\n  }, function (cache) {\n    // Remove token will remove all related style\n    cleanTokenStyle(cache[0]._tokenKey);\n  });\n  return cachedToken;\n}"],"mappings":"AAAA,OAAOA,aAAa,MAAM,0CAA0C;AACpE,OAAOC,kBAAkB,MAAM,8CAA8C;AAC7E,OAAO,K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